#ifndef __STORAGE_H_
#define __STORAGE_H_

#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <iostream>
using namespace std;

class Storage
{
public:
	void GetPiece(unsigned char *buf, unsigned piece, unsigned len);
private:
	int fileLength;
	int numOfPieces;
	int pieceLen;
	bool fileopen;
	int fd;

	// funcionality only available to Peer and Torrent class
	friend class Torrent;
	friend class Peer;
	friend class Piece;
	Storage(string fname,unsigned int pieceLen, unsigned int numofpieces, unsigned int filesizem);
	~Storage();
	bool fileOpen();
	int store(int piece,unsigned int len,char* data);
};


#endif
